<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_SESSION['merchid']){
	$merchid=$this->checklogin();
	unset($_SESSION['merchid']);
}else{
	$merchid=pdo_getcolumn('jy_tour_merch',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'id');
	if(!$merchid){
		$info=pdo_get('core_members',array('id'=>$_SESSION['uid']),array('mobile','nickname','realname'));
		pdo_insert('jy_tour_merch',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1,'jointime'=>time(),'realname'=>$info['realname'],'mobile'=>$info['mobile'],'merchname'=>$info['nickname']));
		$merchid=pdo_insertid();
	}
}
if($_RQ['op']=='main'){
	$return['list']=array();
	set_html('title','核销台');
	
	$mid = $_SESSION['uid'];
	$merch = pdo_get('jy_tour_merch',array('id'=>$merchid,'uniacid'=>$_SESSION['uniacid']));
	if (empty($merch)) {
		exi('您不属于商户，无核销权限!','error');
	}
	$member = pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$merch['mid']),array('nickname','avatar'));
	$return['saler']=$merch;
	$return['member']=$member;
	exi($return);

	exi($return);
}
